version 14.0

log using "\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure4.log", replace
set more off
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      africancabinets_figure4.do                      *;
*       Date:           January 3, 2017                                 *;
*       Author:         Molly Ariotti and Sona Golder                   *;
*       Purpose:      	Produce Figure 4 for CPS African portfolio      *;
*                       allocation paper.                               *;
* 	    Input File:     tmp3.dta which is from Francois, Rainer, and    *;
*                       Trebbi 2015 Econometrica                        *;
*       Output File:    figure4.log, ethnic.eps                         *;
*       Data Output:    none                                            *;             
*       Previous file:  none                                            *;
*       Machine:        laptop                           				*;
*     ****************************************************************  *;
*     ****************************************************************  *;

use "\Users\sgolder\Dropbox\Portfolio Allocation\replication\tmp3.dta"; 


sum; 

desc; 


sort govshare;

gen seats=.;
replace seats=_n/100 if _n<101;
gen ports=.;
replace ports=_n/100 if _n<101;

scatter govshare popshare if leadergroup==0, msymbol(Oh) mcolor(eltblue) msize(vtiny) 
            || scatter govshare popshare if leadergroup==1, msymbol(O) mcolor(red) msize(vtiny)
            || line govshare govshare if popshare<0.5, lcolor(black) clpattern(solid)
            legend(col(1) size(2.5) region(lstyle(color(white))) order(2 1) position(5) ring(0) label(1 "{stSerif:Not Leader's Ethnic Group}") label(2 "{stSerif:Leader's Ethnic Group}"))
            ||,
            xtitle("{stSerif:Ethnic Group Share of Population}", size(3) height(7)) 
            ytitle("{stSerif:Ethnic Group Share of Cabinet Portfolios}" , size(3) height(7))
            xlabel(0 0.2 0.4 0.6 0.8 1.0, nogrid labsize(2.5))
            ylabel(0 0.2 0.4 0.6 0.8 1.0 , nogrid labsize(2.5)) 
            scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));
            
   
graph export "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\ethnic.eps", replace;



sum govshare popshare;

sum govshare popshare if leadergroup==0;

sum govshare popshare if leadergroup==1;

gen error = abs(govshare-popshare);

egen sum_error = sum(error);

gen average_error=sum_error/11749;

sum average_error;

gen error2 = abs(govshare-popshare) if leadergroup==1;

egen sum_error2 = sum(error2);

gen average_error2=sum_error2/720;

sum average_error2;

log close;
exit;

